#include "Screen.h"
Screen* Screen::freeStore = 0;
const int Screen::screenChunk = 24;

Screen::Screen(int x) :i(x) {
	
}

int Screen::get() {
	return i;
}

void* Screen::operator new(size_t size) {
	Screen* p;
	if (!freeStore) {
		size_t chunk = screenChunk * size;
		freeStore = p = reinterpret_cast<Screen*>(new char[chunk]);
		for (; p != &freeStore[screenChunk - 1]; ++p) {
			p->next = p + 1;
		}
		p->next = 0;
	}
	p = freeStore;
	freeStore = freeStore->next;
	return p;
}

void Screen::operator delete(void* p, size_t) {
	(static_cast<Screen*>(p))->next = freeStore;
	freeStore = static_cast<Screen*>(p);
}